package name.as3.managers
{
	import flash.display.DisplayObject;
	import flash.display.Stage;
	import flash.events.Event;
	
	public class RandomPosManager
	{
		private var m_obTarget:DisplayObject ;
		/**∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥构造函数
		 */		
		public function RandomPosManager(obj:DisplayObject)
		{
			super() ;
			m_obTarget = obj ;
			if(m_obTarget)
			{
				m_obTarget.addEventListener(Event.ADDED_TO_STAGE ,toStage_obTarget) ;
			}
		}
		/**
		 *∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥位置分布函数 
		 * @param e
		 * 
		 */		
		private function toStage_obTarget(e:Event):void
		{
			m_obTarget.removeEventListener(Event.ADDED_TO_STAGE ,toStage_obTarget) ;
			var obStage:Stage = m_obTarget.stage ;
			var posX:int = ( obStage.stageWidth - m_obTarget.width) * Math.random() ;
			var posY:int = ( obStage.stageHeight - m_obTarget.height ) * Math.random() ;
			
			
			m_obTarget.x = posX ;
			m_obTarget.y = posY ;
		}

	}
}